{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2 as cv\n",
    "\n",
    "filename = r'E:\\data\\lena.jpg'\n",
    "img = cv.imread(filename)\n",
    "cv.imshow(\"source image\",img)\n",
    "cv.waitKey()\n",
    "cv.destroyAllWindows()\n",
    "\n",
    "# 分解得到图象的BGR各个分量\n",
    "cv.imshow(\"Blue\",img[:,:,0])    #提取蓝色分量       \n",
    "cv.imshow(\"Green\",img[:,:,1])   #提取绿色分量   \n",
    "cv.imshow(\"Red\",img[:,:,2])     #提取红色分量   \n",
    "cv.waitKey()\n",
    "cv.destroyAllWindows()\n",
    "\n",
    "hsv = cv.cvtColor(img,cv.COLOR_BGR2HSV) #将BGR颜色空间转换为HSV颜色空间\n",
    "# 分解得到图象的hsv各个分量\n",
    "cv.imshow(\"Hue\",hsv[:,:,0])     #提取色调分量            \n",
    "cv.imshow(\"Saturation\",hsv[:,:,1])    #提取饱和度分量 \n",
    "cv.imshow(\"Value\",hsv[:,:,2])      #提取亮度分量 \n",
    "cv.waitKey()\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
